package com.pacific.sign.biz.service;

import com.pacific.common.request.CommonRequest;
import com.pacific.common.response.CommonResponse;
import com.pacific.sign.biz.service.impl.RoleMenuService;
import com.pacific.sign.biz.wrapper.CommonWrapper;
import com.pacific.sign.biz.wrapper.aop.LogAnnotation;
import com.pacific.sign.model.po.pac.mbg.PacHcRoleMenu;
import com.pacific.sign.model.po.pac.response.PacHcRoleMenuResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 角色菜单映射
 */
@Service
public class HcRoleMenuServiceImpl extends CommonWrapper implements HcRoleMenuService {

    @Autowired
    private RoleMenuService roleMenuService;

    @LogAnnotation("角色菜单查询")
    public CommonResponse<PacHcRoleMenuResponse> query(CommonRequest<PacHcRoleMenu> request) {
        CommonResponse<PacHcRoleMenuResponse> response = new CommonResponse<PacHcRoleMenuResponse>();
        try {
            response.setResult(roleMenuService.query(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色菜单新增")
    public CommonResponse<Integer> insert(CommonRequest<PacHcRoleMenu> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(roleMenuService.insert(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色菜单更新")
    public CommonResponse<Integer> update(CommonRequest<PacHcRoleMenu> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(roleMenuService.update(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色菜单删除")
    public CommonResponse<Integer> delete(CommonRequest<PacHcRoleMenu> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(roleMenuService.delete(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色菜单id查询")
    public CommonResponse<PacHcRoleMenu> queryById(CommonRequest<Integer> request) {
        CommonResponse<PacHcRoleMenu> response = new CommonResponse<PacHcRoleMenu>();
        try {
            response.setResult(roleMenuService.selectById(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }
}
